package fr.cpe.dp.projet2.model.musicBuilder;

import fr.cpe.dp.projet2.model.musicPlayer.ConsoleMusicPlayer;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.sound.midi.InvalidMidiDataException;
import javax.sound.midi.MidiEvent;
import javax.sound.midi.ShortMessage;

/**
 * 
 * @author Yannick BONNET
 *
 */
public abstract class AbstractMusicBuilder implements IMusicBuilder {
	protected MidiEvent makeEvent(int command, int channel, int data1, int data2, int tic) {
        MidiEvent evenement = null;
        try {
            ShortMessage midiMessage = new ShortMessage();
            midiMessage.setMessage(command, channel, data1, data2);
            evenement = new MidiEvent(midiMessage, tic);
        } catch (InvalidMidiDataException ex) {
            Logger.getLogger(ConsoleMusicPlayer.class.getName()).log(Level.SEVERE, null, ex);
        }
        return evenement;
    }
}
